-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SNOW-1843926: SPCS service events & metrics #1954
base: main
Are you sure you want to change the base?
SNOW-1843926: SPCS service events & metrics #1954
Conversation
0700514
to
70cc699
Compare
great job with design doc and description on the pr! |
elif isinstance(until, str) and until: | ||
until_clause = f"and timestamp <= sysdate() - interval '{until}'" | ||
|
||
return since_clause, until_clause |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since_clause
and until_clause
are always used together - how about returning them as a single string (" AND ".join([since_clause, until_clause])
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, we want customers have the flexibility of using these individually, Hence separated clauses
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant it more as code reformat - functionality does not change. It felt weird for me that a function returns a tuple, which you always have to join into a string, rather than returning string ready to be used.
This is not blocking though, feel free to resolve
"snowflake.cli.api.feature_flags.FeatureFlag.ENABLE_SPCS_SERVICE_METRICS.is_disabled" | ||
) | ||
@patch("snowflake.cli._plugins.spcs.services.manager.ServiceManager.execute_query") | ||
def test_latest_metrics(mock_execute_query, mock_is_disabled, runner): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we check what rows were printed as well (to check whether formatting / show all columns flag works as expected). snapshot
fixture and pytest.mark.parametrize
might be useful - you can check out test_help_messages
for usage example :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see the changes - did you push the latest version?
I thought about adding
assert result.output == snapshot
using snapshot fixture - this way we could check the row formatting functions
You can do the same with expected_query
(assert actual_query == snapshot
) - this way the test code would become cleaner ;)
72e4916
to
d8e47b7
Compare
5411ad2
to
5f38795
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments were marked as resolved without a change - did you forget to push?
(if not - please leave a comment why)
5f38795
to
281ca39
Compare
Pre-review checklist
Changes description
Design Document
1. Events Command:
snow spcs service events
2. Metrics Command:
snow spcs service metrics
Change Motivation
Alternate Approach: Standalone Command (
snow spcs events
)Unified Command Consideration: Instead of separate commands for metrics and events, a unified
snow spcs events
command was considered. This would handle both service and compute pool telemetry.Given these drawbacks, the current design with distinct commands was chosen for clarity and future extensibility.
Design Logic
Required Parameters
For both events and metrics, the following parameters are mandatory to ensure precise identification of the service and its resources:
name
: Service identifier (Service name).--container-name
: Name of the container.--instance-id
: Instance ID of the service (starting with 0).Filtering Options
Time-Based Filters:
--since
: Fetch telemetry data newer than the specified time (e.g.,1h
,5d
).--until
: Fetch telemetry data older than the specified time.Pagination (for Events Only):
--first <N>
: Fetch only the first N events.--last <N>
: Fetch only the last N events.--first
and--last
are mutually exclusive.All Columns Display:
--all
: Fetch all columns from the event or metrics table.Behavior for Metrics
No Filters Provided (
--since
,--until
not used):With Any Filters (
--since
,--until
):Data Formats
Events (Formatted Data)
Metrics (Formatted Data)
Raw Data (
--all
Flag)Use Cases
snow spcs service events
Narrow the time range using interval syntax:
snow spcs service events LOG_EVENT --container-name log-printer --instance-id 0 --since '5 minutes'
Output :
snow spcs service events LOG_EVENT --container-name log-printer --instance-id 0 --until '1 hour'
Retrieve all events with all columns displayed:
Output: Raw table including all available columns.
Retrieve events formatted for JSON output:
Output (JSON):
snow spcs service metrics
Retrieve a subset of metrics with pagination:
Fetch the first 5 metrics:
Or fetch the last 5 metrics:
Output: Formatted table showing the first or last 5 metrics.
Retrieve metrics within a time range:
Fetch metrics newer than 1 hour:
snow spcs service metrics LOG_EVENT --container-name log-printer --instance-id 0 --since '1 hour'
Fetch metrics older than 2 hours:
snow spcs service metrics LOG_EVENT --container-name log-printer --instance-id 0 --until '2 hours'
Output: Metrics within the specified time range.
Retrieve metrics with all columns:
Output: Raw table showing the last metric with all columns.
Retrieve metrics formatted for JSON output:
Output (JSON):